//
//  AXFCircleAniLayer.m
//  BEEQUICK
//
//  Created by admin on 23/11/2016.
//  Copyright © 2016 SevenGroup. All rights reserved.
//

#import "AXFCircleAniLayer.h"
#import <UIKit/UIKit.h>

@implementation AXFCircleAniLayer

- (void)drawInContext:(CGContextRef)ctx {
	CGPoint center = CGPointMake(0.5 * kSCREENWIDTH, 93);
	
	CGFloat outerR = 75;
	CGFloat innerR = 56;
	
	CGFloat outerLineW = 40.0;
	CGFloat innerLineW = 20.0;
	
	UIBezierPath *outerPath = [UIBezierPath bezierPathWithArcCenter:center radius:outerR - outerLineW / 2 startAngle:0.f endAngle:M_PI * 2 * self.progress clockwise:YES];
	UIBezierPath *innerPath = [UIBezierPath bezierPathWithArcCenter:center radius:innerR - innerLineW / 2 startAngle:0.f endAngle:M_PI * 2 * self.progress clockwise:YES];
	
	CGContextSetRGBStrokeColor(ctx, .86, .86, .86, 1);
	CGContextSetLineWidth(ctx, 40);//线条宽度
	CGContextAddPath(ctx, outerPath.CGPath);
	CGContextStrokePath(ctx);
	
	CGContextSetRGBStrokeColor(ctx, .78, .78, .78, 1);
	CGContextSetLineWidth(ctx, 20);//线条宽度
	CGContextAddPath(ctx, innerPath.CGPath);
	CGContextStrokePath(ctx);
}

- (instancetype)initWithLayer:(AXFCircleAniLayer *)layer {
	if (self = [super initWithLayer:layer]) {
		self.progress = layer.progress;
	}
	return self;
}

+ (BOOL)needsDisplayForKey:(NSString *)key {
	if ([key isEqualToString:@"progress"]) {
		return YES;
	}
	return [super needsDisplayForKey:key];
}

@end
